package com.yuanzong.wuliu.controller.admin.auth;

import com.yuanzong.wuliu.common.vo.ApiResult;
import com.yuanzong.wuliu.controller.admin.auth.param.AdminRuntimeUserModifyPasswordParam;
import com.yuanzong.wuliu.service.admin.auth.AdminRuntimeUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@Api(tags = "管理端 - 登录用户")
@RequestMapping("/admin/auth/runtimeUser")
@Slf4j
public class AdminRuntimeUserController {

    @Autowired
    private AdminRuntimeUserService adminRuntimeUserService;

    @ApiOperation("登陆用户信息")
    @RequestMapping(value = "/info", method = {RequestMethod.POST})
    public ApiResult info() throws Exception {
        ApiResult result = adminRuntimeUserService.info();
        return result;
    }

    @ApiOperation("修改密码")
    @RequestMapping(value = "/modifyPassword", method = {RequestMethod.POST})
    public ApiResult modifyPassword(@RequestBody AdminRuntimeUserModifyPasswordParam param) throws Exception {
        ApiResult result = adminRuntimeUserService.modifyPassword(param);
        return result;
    }

    @ApiOperation("退出登录")
    @RequestMapping(value = "/logout", method = {RequestMethod.POST})
    public ApiResult logout() throws Exception {
        ApiResult result = adminRuntimeUserService.logout();
        return result;
    }
}
